<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>解密</title>
    <!--<script type="text/javascript" src="js/manhuaDate.1.0.js"></script>-->
    <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
    <link rel="stylesheet" type="text/css" href="css/hotel.css"/>
    <script type="text/javascript" src="layer/layer.js"></script>
    <!--<link rel="stylesheet" type="text/css" href="css/manhuaDate.1.0.css" />-->
</head>
<body class="decode-body">
<input type="hidden" id="userName" th:value="${session.UserName}"/>
<script type="text/javascript">
    var uname = $('#userName').val();
    if(uname == ''){
        window.location.href = "toLogin.do";
    }
</script>
<form action="" method="post">
    <div class="decode">
        <div class="decode-text"><label for="userPassword">输入密码:</label></div>
        <div class="decode-input">
            <input type="password" id="userPassword"/>
        </div>
    </div>
    <div class="btndecode">
        <button class="btn-decode" type="button" id="btn-decode">确定</button>
    </div>
</form>
<script language="javascript">
    //		防止页面后退
    history.pushState(null, null, document.URL);
    window.addEventListener('popstate', function () {
        history.pushState(null, null, document.URL)
    });
    var userPassword;
    $('#userPassword').blur(checkPassword);
    function checkPassword() {
        userPassword = $('#userPassword').val();
        var reg_userPassword = /^\w{6,10}$/;
        var flag = reg_userPassword.test(userPassword);
        if (flag) {
            $("#userPassword").css("border", "");
        } else {
            layer.tips('密码需满足6到10位', '#userPassword');
            $("#userPassword").css("border", "1px solid red");
        }
        return flag;
    }
    $('#btn-decode').click(function (){
        if(checkPassword()){
            var uname = $('#userName').val();
            $.post(
                "decode.do",
                {"uname":uname,"userPassword":userPassword},
                function (data){
                    if (data.status == 0) {
                        window.location.href = "toIndex.do";
                    } else if (data.status == 1) {
                        layer.msg(data.message);
                    }
                }
            );
        }else {
            layer.msg("请将信息填写正确");
        }
    })
</script>
</body>
</html>
